// Chat Program for PCMod (CLIENT)

PROG.PName = "AlarmZ"
PROG.Author = "[GU]|ZLC|thomasfn"

PROG.NiceName = "AlarmZ"

PCMod.AL = {}

function PROG:BuildWindow( WindowName, Desktop, Object )
	// Here we build the derma window.
	// Note the Desktop string is needed for every operation involving derma.
	
	if (WindowName == "Main") then		
	
		// Add the HTML Box area
		local pn = vgui.Create( "DImage" )
		pn:SetParent( Object )
		pn:SetPos( 5, 50 )
		pn:SetSize( Object:GetWide()-10, Object:GetTall()-55 )
		pn:SetImage( "models/rendertarget" )
		PCMod.AL.RT = pn
		
		// Add the buttons
		DInterface:AddButton( "btnEnable", Desktop, "Enable Alarm", 5, 25, 100, 20, function()
			RunConsoleCommand( "pc_command", "prog_command", "play", "ambient/alarms/alarm1.wav" )
			// ^ Couldn't be bothered to use the PCMod function to do this lol :P
		end )
		DInterface:AddButton( "btnDisable", Desktop, "Disable Alarm", 105, 25, 100, 20, function()
			RunConsoleCommand( "pc_command", "prog_command", "stop" )
		end )
		
		self.Desktop = Desktop
		
	end
	
	// Add a quit button
	DInterface:AddButton( "btnQuit", Desktop, "X", Object:GetWide()-20, 0, 20, 20, function() SendCommand( "quit" ); end )
end

function PROG:ClearWindow( Desktop )
	// Here we destroy EVERY derma control that MIGHT exist.
	
	DInterface:RemoveButton( "btnEnable", Desktop )
	DInterface:RemoveButton( "btnDisable", Desktop )
	
	if (PCMod.AL.RT) then
		PCMod.AL.RT:Remove()
		PCMod.AL.RT = nil
	end
	
	DInterface:RemoveButton( "btnQuit", Desktop )
end

// Data[1] = Tag
// Data[2] = Content
function PROG:DataRecieved( Desktop, Data )
	// The server has sent us some data
end

// Custom Functions

function PROG:Paint( x, y, w, h )
	--draw.RoundedBox( 4, x+(w*0.05), y+(h*0.1), w*0.9, h*0.75, Color( 255, 255, 255, 200 ) )
end